#!/bin/bash

. ./path.sh || exit 1;

export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7"
stage=5 # start from 0 if you need to start from data_list preparation
stop_stage=5

dir=./exp
train_config=/home/work_nfs8/xlgeng/new_workspace/wenet_gxl_salmonn_TTS/examples/aishell/ASR_TTS/exp/V_1_TTS_training/step_13566.yaml
decode_checkpoint=/home/work_nfs8/xlgeng/new_workspace/wenet_gxl_salmonn_TTS/examples/aishell/ASR_TTS/exp/V_1_TTS_training/step_13566.pt

gpu_id=3
decode_modes="salmonn_decode"
test_data_dir=//home/work_nfs8/xlgeng/new_workspace/wenet_gxl_salmonn_TTS/examples/aishell/wenetspeech4tts_handler/data_list
data_type=raw
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
  ctc_weight=0.5
  echo "耿雪龙 test this dataset"
  test_dir=$dir/wer_output
  mkdir -p $test_dir
  export CUDA_VISIBLE_DEVICES=$gpu_id
  python wenet/bin/recognize.py --gpu $gpu_id \
    --modes $decode_modes \
    --config $train_config \
    --data_type $data_type \
    --test_data $test_data_dir/cv_wtn.list \
    --checkpoint $decode_checkpoint \
    --beam_size 10 \
    --batch_size 1 \
    --penalty 0.0 \
    --result_dir $test_dir \
    --ctc_weight $ctc_weight \


#    python tools/compute-wer.py --char=1 --v=1 \
#      data_list/test/$test_set/text $test_dir/text_hyp > $test_dir/wer
  echo "$test_set has been decoded!"
  python tools/compute-wer.py --char=1 --v=1 \
    $test_data_dir/cv_token.scp $test_dir/text > $test_dir/wer

fi
if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then
  ctc_weight=0.5
  for test_set in "${test_sets[@]}"; do
  {
    echo "compute wer this dataset: $test_set"
    test_dir=$dir/test_${decode_checkpoint_name}_${test_set_suffix}/${test_set}
    python tools/compute-wer.py --char=1 --v=1 \
      $test_data_dir/$test_set/text $test_dir/text > $test_dir/wer
    echo "$test_set has been decoded!"
  }
  done
  wait

fi
